<div id="sidebar">

<SCRIPT language=JavaScript> 
function Year_Month(){ 
	
var now = new Date(); 
var yy = now.getFullYear(); 
var mm = now.getMonth()+1; 
var cl = '<font color="#ffffff">'; 
if (now.getDay() == 0) cl = '<font color="#ffffff">'; 
if (now.getDay() == 6) cl = '<font color="#ffffff">'; 
return(cl + yy + '年' + mm + '月</font>'); } 
function Date_of_Today(){ 
var now = new Date(); 
var cl = '<font color="#ffffff">'; 
if (now.getDay() == 0) cl = '<font color="#ffffff">'; 
if (now.getDay() == 6) cl = '<font color="#ffffff">'; 
return(cl + now.getDate() + '</font>'); } 
function Day_of_Today(){ 
var day = new Array(); 
day[0] = "星期日"; 
day[1] = "星期一"; 
day[2] = "星期二"; 
day[3] = "星期三"; 
day[4] = "星期四"; 
day[5] = "星期五"; 
day[6] = "星期六"; 
var now = new Date(); 
var cl = '<font color="#ffffff">'; 
if (now.getDay() == 0) cl = '<font color="#ffffff">'; 
if (now.getDay() == 6) cl = '<font color="#ffffff">'; 
return(cl + day[now.getDay()] + '</font>'); } 
function CurentTime(){ 
var now = new Date(); 
var hh = now.getHours(); 
var mm = now.getMinutes(); 
var ss = now.getTime() % 60000; 
ss = (ss - (ss % 1000)) / 1000; 
var clock = hh+':'; 
if (mm < 10) clock += '0'; 
clock += mm+':'; 
if (ss < 10) clock += '0'; 
clock += ss; 
return(clock); } 
function refreshCalendarClock(){ 
document.getElementById("calendarClock1").innerHTML = Year_Month(); 
document.getElementById("calendarClock2").innerHTML = Date_of_Today(); 
document.getElementById("calendarClock3").innerHTML = Day_of_Today(); 
document.getElementById("calendarClock4").innerHTML = CurentTime(); } 
setInterval('refreshCalendarClock()',1000); 
</SCRIPT>
<div class="time">
	<p id = "calendarClock1"></p>
	<p id = "calendarClock2"></p>
	<p id = "calendarClock3"></p>
	<p id = "calendarClock4"></p>
</div>
<ul>

  <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
	

    <li>
      <?php //include (TEMPLATEPATH . '/searchform.php'); ?>
    </li>

    <?php /* Menu for subpages of current page (copied from K2 theme) */
    global $notfound;
    if (is_page() and ($notfound != '1')) {
        $current_page = $post->ID;
        while($current_page) {
            $page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
            $current_page = $page_query->post_parent;
        }
        $parent_id = $page_query->ID;
        $parent_title = $page_query->post_title;

        // if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) {
        if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_type != 'attachment'")) {
    ?>

    <li>
      <h2 class="sidebartitle"><?php echo $parent_title; ?> <?php _e('Subpages'); ?></h2>
      <ul class="list-page">
        <?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?>
      </ul>
    </li>

    <?php } } ?>

    <li>
      <h2 class="sidebartitle"><?php _e('最新文章'); ?></h2>
      <ul class="list-cat">
        <? get_archives('postbypost',3);?>
      </ul>
    </li>
	<li>
      <h2 class="sidebartitle"><?php _e('Categories'); ?></h2>
      <ul class="list-cat">
        <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
      </ul>
    </li>
    <li>
      <h2 class="sidebartitle"><?php _e('Archives'); ?></h2>
      <ul class="list-archives">
        <?php wp_get_archives('type=monthly'); ?>
      </ul>
    </li>

  <?php endif; ?>

    <li>
		<h2><?php _e('Meta'); ?></h2>
		<ul>
			<?php wp_register(); ?>
			<li><?php wp_loginout(); ?></li>
			<?php wp_meta(); ?>
		</ul>
	</li>

 </ul>
</div>
<!--/sidebar -->